$('.right-titleicon').on("click", function(e) {
	projectVM.showMenulist()
})
document.addEventListener('focusout', function(e) {
	var classList = document.body.classList
	if (classList.contains('mui-focusin')) {
		classList.remove('mui-focusin')
	}
})
projectVM = new Vue({
	el: "#content",
	data: {
		baseForm: {}, // 考虑到可能修改传入参数，所以要防止直接引用
		cfmData: { // 确认框数据
			workStatus: '', // 当前节点
			workType: '',
			workDesc: '',
			workId: '',
			type: '', // 推进类型（forward：向前、backward：向后）
			// 显示内容
			questionArr: [], // 缺陷描述列表
			approver: '', // 审核人
			opinion: '', // 意见描述
			deviceNum: 0 // 已检查设备数量
		},
		checked: false,
		checkedNames: [],
		collectionList: [],
		partHisList: [],
		// 检测数据
		weatherList: [],
		addId: '',
		detectionList: [],
		// 设备信息
		deviceForm: {
			tableData: [] // 列表集合
		},
		tableLoading: false, // 列表Loading
		// editable: JSON.parse(localStorage.getItem('todoWork')).editable,
		// 部位信息
		partForm: {
			tableData: [] // 列表集合
		},
		showAdd: false,
		approveDesc: '',
		approveDialogTips: true,
		isApprove: false,
		isMyEditor: false,
		workStatus: '20',
		dealingPerson: 'P129951',
		//dealingPerson: 'P129952',
		// 是否是编辑
		isEdit: false,
		active: '',
		// 编辑对应行
		index: 0,
		approveCodeName: '',
		workDesc: '网络安全',
		workType: '0115',
		// 流程id
		workId: "3d7bf4a9c239442c99a8708f55149ee2", // 获取流程日志所需待办Id
		workNodeId: '123',
		workLastDate: '',
		addOrEdit: false,
		isEditor: false,
		initNetSafeDeviceInfoList: [],
		formData: {
			networkSafeInfoId: '', // 网络安全防护设备检查明细主键
			networkSafeId: '', // 网络安全防护设备检查批次主键
			checkDate: 123,
			checkStaffCodeName: 'alwin', // 新增时测试人为当前登陆人
			checkStaffCode: 'p123123',
			checkStaffName: 'asd',
			deviceName: '', //设备名称
			bay: '', // 所属间隔
			isWarning: '0', // 默认不告警
			isAmbientNormal: '1', // 默认环境正常
			isHaveAbnormalDevice: '0', // 默认无不正常设备
			problemLog: '' // 问题记录
		},
		onStatus: false,
		showPop: false,
		showMenu: false,
		showAdd: false,
		nodeLogList: [],
		tutelageStaffName: '',
		tutelageStaffCode: '',
		disabled: false,
		elseDesc: '',
		//删除数据
		delNetSafeDeviceInfoList: [],
		networkSafe: {
			"networkSafeId": "",
			"workId": "",
			"workDesc": "网络安全防护设备定期检查",
			"elseDesc": ""
		},
		defectInfoList: [],
		menuList: [{
			name: '新增',
			path: 'list.html'
		}, {
			name: '列表',
			path: 'index.html'
		}, ],
		filterText: 'all', //筛选条件
		list: [],
		currentUser: {},
	},
	components: {
		personselect,
		processlog
	},
	created() {
		console.log(localStorage.getItem('neiosUser'))
		console.log(localStorage.getItem('todoWork'))
		this.baseForm = Object.assign({}, JSON.parse(localStorage.getItem('todoWork')).obj)
		this.cfmData = { // 确认框数据
				workStatus: JSON.parse(localStorage.getItem('todoWork')).obj.workStatus, // 当前节点
				workType: JSON.parse(localStorage.getItem('todoWork')).obj.workType,
				workDesc: JSON.parse(localStorage.getItem('todoWork')).obj.workDesc,
				workId: JSON.parse(localStorage.getItem('todoWork')).obj.workId,
				type: '', // 推进类型（forward：向前、backward：向后）
				// 显示内容
				questionArr: [], // 缺陷描述列表
				approver: '', // 审核人
				opinion: '', // 意见描述
				deviceNum: 0 // 已检查设备数量
			},
			this.workLastDate = JSON.parse(localStorage.getItem('todoWork')).obj.workLastDate
		this.workId = JSON.parse(localStorage.getItem('todoWork')).obj.workId
		this.workNodeId = JSON.parse(localStorage.getItem('todoWork')).obj.workNodeId
		this.workStatus = JSON.parse(localStorage.getItem('todoWork')).obj.workStatus
		this.currentUser = JSON.parse(localStorage.getItem('neiosUser'))
		this.active = JSON.parse(localStorage.getItem('todoWork')).obj.workStatus

		this.disabled = JSON.parse(localStorage.getItem('todoWork')).obj.workStatus > '30' 
		console.log(this.disabled)
		let dictCodes = 'WEATHER';
		let dict = mui.neiosCommon.queryDict(dictCodes, (data) => {
			if (data != '') {
				this.weatherList = data.WEATHER;
			}
		})
		//设备红外详情
		mui.neiosRequst.httpRequst('/app/personWork/getNodeLogByWorkId', {
				'workId': this.workId
			},
			(data) => {
				if (data.code == '0') {
					console.log(data.data)
					this.nodeLogList = data.data;
					// 新增时监护人信息
					if (this.active == '20') {
						let tutelageStaffInfo = this.nodeLogList.filter(v => v.node_deal_staff_code != this.currentUser["userId"]);
						if (tutelageStaffInfo.length > 0) {
							let tutelageStaff = tutelageStaffInfo[0];
							this.tutelageStaffName = tutelageStaff.node_deal_staff_name;
							this.tutelageStaffCode = tutelageStaff.node_deal_staff_code;
						}
					}
					let param = {
						"workId": this.workId,
						"workNodeId": this.workNodeId,
					}
					mui.neiosRequst.httpRequst('/app/regularWork/infrared/getInfraredDetails', param,
						(data) => {
							if (data.code == '0') {
								console.log(JSON.stringify(data.data))
								this.dealResultData(data.data);
								this.setDefectList();
								// this.list = data.data.networkSafeInfoList ? data.data.networkSafeInfoList : [],
								// 	this.list.map((v, i) => {
								// 		v.dataSource = 'NEIOS_APP'
								// 	})
								// this.networkSafe.networkSafeId = data.data.networkSafeId
								// this.networkSafe.workId = this.workId
								// this.elseDesc = data.data.elseDesc == null ? "" : data.data.elseDesc;
								console.log(JSON.stringify(data.data))

							}
						},
						(data) => {
							mui.toast("获取数据错误：" + data.msg);
						}
					);
				} else {
					mui.toast("获取数据失败：" + data.msg);
				}
			},
			(data) => {
				mui.toast("获取数据失败：" + data.msg);
			}
		);
	},
	beforeDestroy() {},
	watch: {

		"checkedNames": function() {
			if (this.checkedNames.length == this.collectionList.length) {

				this.checked = true

			} else {

				this.checked = false

			}

		}

	},
	methods: {
		// 添加到当日检测记录
		addTo() {
			this.checkedNames.map(item => {
				let infraredDeviceId = mui.neiosCommon.getUuidv4();
				this.deviceForm.tableData.push({
					infraredDeviceId: infraredDeviceId,
					infraredDetectionId: this.addId,
					bay: item.bay,
					deviceName: item.deviceName,
					dataType: 'add'
				});
				this.checkedNames.map(it => {
					if (it.infraredDeviceId == item.infraredDeviceId) {
						this.partForm.tableData.push({
							infraredPartId: mui.neiosCommon.getUuidv4(),
							infraredDeviceId: infraredDeviceId,
							partName: it.partName,
							surfaceTA: it.surfaceTA,
							surfaceTB: it.surfaceTB,
							surfaceTC: it.surfaceTC,
							ambientT: it.ambientT,
							humidity: it.humidity,
							defectPart: it.defectPart,
							dataType: 'add'
						});
					}
				});
			});
			this.showAdd = false
		},
		// 打开设备历史
		openAddDialog(id) {
			let params = JSON.parse(localStorage.getItem('todoWork')).obj
			params.pageSize = 999
			params.pageIndex = 1
			mui.neiosRequst.httpRequst('/app/regularWork/infrared/getInfraredDeviceHis', params,
				(data) => {
					if (data.code == '0') {
						console.log(JSON.stringify(data.data.records))
						this.dealDialogResultData(data.data)
					} else {
						mui.toast("获取数据失败：" + data.msg);
					}
				},
				(data) => {
					mui.toast("获取数据失败：" + data.msg);
				}
			);
			this.addId = id
			this.showAdd = true
		},
		// 返回值处理
		dealDialogResultData(data) {
			// 此处一定至少有一条记录
			let records = data.records;
			// 设备历史列表
			let deviceIds = records[0].infraredDeviceId == null ? [] : [records[0].infraredDeviceId];
			this.collectionList = (records[0].infraredDeviceId == null ? [] : [records[0]]).concat(records.filter((item,
				index, arr) => {
				let itIdNotIn = deviceIds.indexOf(item.infraredDeviceId) == -1;
				if (itIdNotIn) {
					deviceIds.push(item.infraredDeviceId);
				}
				return index > 0 && itIdNotIn;
			}));
			// 部位历史列表
			this.partHisList = records;
		},
		changeAllChecked: function() {

			if (this.checked) {
				this.checkedNames = this.collectionList
			} else {

				this.checkedNames = []

			}

		},
		// 返回值处理
		dealResultData(data) {
			// data[0].dataStatus = data[0].infraredBaseId == null ? null : data[0].dataStatus;
			// data[0].infraredBaseId = data[0].infraredBaseId == null ? commonNeios.uuid() : data[0].infraredBaseId;
			// 基本信息
			if (data.length > 0) {
				this.baseForm = data[0];
			} else {
				this.baseForm.infraredBaseId = mui.neiosCommon.getUuidv4()
			}
			if (this.active == "20") {
				this.baseForm.surveyCode = this.currentUser["userId"];
				this.baseForm.surveyName = this.currentUser["name"];
				this.baseForm.surveyStaff = `[${this.currentUser["userId"]}]${this.currentUser["name"]}`;
				this.baseForm.tutelageCode = this.tutelageStaffCode;
				this.baseForm.tutelageName = this.tutelageStaffName;
				this.baseForm.tutelageStaff = `[${this.tutelageStaffCode}]${this.tutelageStaffName}`;
			}
			// 设备红外检测记录
			let detectionIds = [];
			if (data.length > 0) {
				detectionIds = [data[0].infraredDetectionId];
				this.detectionList = (data[0].infraredDetectionId == null ? [] : [data[0]]).concat(data.filter((item, index, arr) => {
					let itIdNotIn = detectionIds.indexOf(item.infraredDetectionId) == -1;
					if (itIdNotIn) {
						detectionIds.push(item.infraredDetectionId);
					}
					return index > 0 && itIdNotIn;
				})).map((item, index) => {
					item.dtcMonthDay = this.getTime(new Date(item.dtcDate), 'day').substr(5).replace('-', '月') + '日';
					return item;
				});
			}
			// 被检测设备信息
			let deviceIds = [];
			if (data.length > 0) {
				deviceIds = [data[0].infraredDeviceId];
				this.deviceForm.tableData = (data[0].infraredDeviceId == null ? [] : [data[0]]).concat(data.filter((item, index,
					arr) => {
					let itIdNotIn = deviceIds.indexOf(item.infraredDeviceId) == -1;
					if (itIdNotIn) {
						deviceIds.push(item.infraredDeviceId);
					}
					return index > 0 && itIdNotIn;
				}));
			}
			// 被检测部位信息
			let partIds = [];
			if (data.length > 0) {
				partIds = [data[0].infraredPartId];
				this.partForm.tableData = (data[0].infraredPartId == null ? [] : [data[0]]).concat(data.filter((item, index, arr) => {
					let itIdNotIn = partIds.indexOf(item.infraredPartId) == -1;
					if (itIdNotIn) {
						partIds.push(item.infraredPartId);
					}
					return index > 0 && itIdNotIn;
				}));
			}
			if ((this.active == "20" || this.active == "30")) {
				// 从任务领取日期开始，截至日期为止，若有缺省记录，则进行创建
				let now = this.getTime(new Date(), 'day');
				let startDate = this.getTime(new Date(this.workLastDate.replace('-', '/')), 'day');
				let endDate = this.getTime(new Date(), 'day');
				for (let date = startDate; date <= now && date <= endDate;) {
					// 如果没有当前日期的检测记录，则进行创建
					if (this.detectionList.map(item => this.getTime(new Date(item.dtcDate.replace('-', '/')), 'day')).indexOf(
							date) == -1) {
						// 先创建折叠板
						// 再添加数据
						let infraredDetectionId = mui.neiosCommon.getUuidv4()
						this.detectionList.unshift({
							infraredDetectionId: infraredDetectionId,
							infraredBaseId: this.baseForm.infraredBaseId,
							dtcDate: date,
							dtcMonthDay: date.substr(5).replace('-', '月') + '日',
							weather: '0',
							dataType: 'add'
						});
						this.addDevice(infraredDetectionId);
					}
					// 循环变量步进
					let dLong = new Date(date).getTime();
					date = this.getTime(new Date(dLong + 24 * 60 * 60 * 1000), 'day');
				}
			}
			// 根据检测日期排序
			this.detectionList.sort((a, b) => new Date(b.dtcDate).getTime() - new Date(a.dtcDate).getTime());
		},
		// 删除部位
		delPart(row) {
			var btnArray = ['取消', '确定'];
			mui.confirm('是否确认删除？', '提示', btnArray, (e) => {
				if (e.index == 1) {
					this.partForm.tableData = this.partForm.tableData.filter((item, index) => {
						if (item.infraredPartId == row.infraredPartId && item.dataType == 'db') {
							item.dataStatus = '0';
						}
						return item.infraredPartId != row.infraredPartId || item.dataType == 'db'
					});
					this.onPartBlur('defectPart'); // 修改结论
				} else {

				}
			})
		},
		// 删除设备
		delDevice(row) {
			var btnArray = ['取消', '确定'];
			mui.confirm('是否确认删除？', '提示', btnArray, (e) => {
				if (e.index == 1) {
					this.deviceForm.tableData = this.deviceForm.tableData.filter((item, index) => {
						if (item.infraredDeviceId == row.infraredDeviceId && item.dataType == 'db') {
							item.dataStatus = '0';
						}
						return item.infraredDeviceId != row.infraredDeviceId || item.dataType == 'db';
					});
					// 删除部位
					this.partForm.tableData = this.partForm.tableData.filter((item, index) => {
						if (item.infraredDeviceId == row.infraredDeviceId && item.dataType == 'db') {
							item.dataStatus = '0';
						}
						return item.infraredDeviceId != row.infraredDeviceId || item.dataType == 'db';
					});
					this.onPartBlur('defectPart'); // 修改结论
				} else {

				}
			})
		},
		// 新增设备
		addDevice(infraredDetectionId) {
			let infraredDeviceId = mui.neiosCommon.getUuidv4();
			this.deviceForm.tableData.push({
				infraredDeviceId: infraredDeviceId,
				infraredDetectionId: infraredDetectionId,
				bay: '',
				deviceName: '',
				dataType: 'add'
			});
			this.addPart(infraredDeviceId);
		},
		// 新增部位
		addPart(infraredDeviceId) {
			this.partForm.tableData.push({
				infraredPartId: mui.neiosCommon.getUuidv4(),
				infraredDeviceId: infraredDeviceId,
				partName: '',
				surfaceTA: '',
				surfaceTB: '',
				surfaceTC: '',
				ambientT: '',
				humidity: '',
				defectPart: '',
				dataType: 'add'
			});
		},
		clickStop() {

		},
		//判断是否显示办理
		isShowHandle() {
			if (this.workStatus == '30') {
				return true
			} else {
				return false
			}
		},
		//判断是否显示编辑
		isShowEdit() {
			if (this.workStatus == '20') {
				return true
			} else {
				return false
			}
		},
		//获取时间
		getTime(myDate, type) {
			var realYear = myDate.getFullYear();
			var myMonth = myDate.getMonth() + 1;
			var realMonth = myMonth;
			var myDay = myDate.getDate();
			var realDay = myDay;
			var myHour = myDate.getHours();
			var realHours = myHour;
			var myMinute = myDate.getMinutes();
			var realMinute = myMinute;
			var mySecond = myDate.getSeconds();
			var realSecond = mySecond;
			if (myMonth < 10) {
				realMonth = "0" + myMonth;
			}
			if (myDay < 10) {
				realDay = "0" + myDay;
			}
			if (myMinute < 10) {
				realMinute = "0" + myMinute;
			}
			if (myHour < 10) {
				realHours = "0" + myHour;
			}
			if (mySecond < 10) {
				realSecond = "0" + mySecond;
			}
			var realDate = realYear + '-' + realMonth + '-' + realDay + ' ' + realHours + ':' + realMinute + ':' +
				realSecond;
			if (type == "sec") {
				realDate = realYear + '-' + realMonth + '-' + realDay + ' ' + realHours + ':' + realMinute + ':' + realSecond;
			} else if (type == "min") {
				realDate = realYear + '-' + realMonth + '-' + realDay + ' ' + realHours + ':' + realMinute;
			} else if (type == "hour") {
				realDate = realYear + '-' + realMonth + '-' + realDay + ' ' + realHours;
			} else if (type == "day") {
				realDate = realYear + '-' + realMonth + '-' + realDay;
			} else if (type == "month") {
				realDate = realYear + '-' + realMonth;
			} else if (type == "year") {
				realDate = realYear;
			}
			return realDate;
		},
		navTo(e, data) {
			if (data) {
				window.localStorage.setItem("itme", JSON.stringify(data))
			} else {
				window.localStorage.setItem("itme", '')
			}
			mui.openWindow({
				url: e,
				id: 'my',
				extras: {
					'item': data
				},
				waiting: {
					autoShow: false
				}
			});
		},
		// 初始化隐患描述
		initDefectInfo() {
			// this.showAdd = true
		},
		// 关闭弹窗
		clearDefectInfo() {
			this.showAdd = false
		},
		// 退回
		approveInitDefectInfo() {
			let params = this.dealParamData()			this.cfmData = Object.assign({}, this.cfmData, params);
			let deviceNames = [];
			this.cfmData.deviceNum = this.cfmData.deviceList.filter(item => {
				let itNameNotIn = item.deviceName != '' && deviceNames.indexOf(item.deviceName) == -1;
				return itNameNotIn;
			}).length;
			this.cfmData.type = 'backward'
			this.isApprove = true
			// this.list.forEach(e => {
			// 	if (e.isWarning != '0') {
			// 		let defectInfoDesc = `网络安全防护设备定期检查：[${e.bay}]${e.deviceName}。检查项：是否有告警。不合格`;
			// 		this.defectInfoList.push({
			// 			"defectInfoDesc": defectInfoDesc
			// 		});
			// 	}
			// 	if (e.isAmbientNormal != '1') {
			// 		let defectInfoDesc = `网络安全防护设备定期检查：[${e.bay}]${e.deviceName}。检查项：运行环境是否正常。不合格`;
			// 		this.defectInfoList.push({
			// 			"defectInfoDesc": defectInfoDesc
			// 		});
			// 	}
			// 	if (e.isHaveAbnormalDevice != '0') {
			// 		let defectInfoDesc = `网络安全防护设备定期检查：[${e.bay}]${e.deviceName}。检查项：是否有非正常业务设备。不合格`;
			// 		this.defectInfoList.push({
			// 			"defectInfoDesc": defectInfoDesc
			// 		});
			// 	}
			// })
		},
		// 去除空数据
		removeEmpty(list) {
			let excludes = ['weather', 'dataType', 'dataStatus'];
			return list.filter((item, index) => {
				let isEmpty = true;
				for (let key in item) {
					if (key.indexOf('Id') == -1 && excludes.indexOf(key) == -1) {
						isEmpty = isEmpty && item[key] == '';
					}
				}
				item.orderNum = index + 1;
				return !isEmpty;
			});
		},
		// 保存或提交时的数据处理20 创建人 30 监护人 40 审核人
		dealParamData() {
			var that = this
			let deviceList = this.removeEmpty(this.deviceForm.tableData);
			let partList = this.removeEmpty(this.partForm.tableData);
			let detectionIds = deviceList.map(item => item.infraredDetectionId);
			let detectionList = this.detectionList.filter(item => detectionIds.indexOf(item.infraredDetectionId) > -1);
			let infraredBase = Object.assign(this.baseForm, {
				allDate: detectionList.slice().reverse().map(item => item.dtcDate.substr(5).replace('-', '.')).join('、'),
				firstWeather: detectionList.length == 0 ? '' : detectionList[detectionList.length - 1].weather,
				avgAmbientT: eval(partList.map(item => Number(item.ambientT)).join('+')) / partList.length,
				avgHumidity: eval(partList.map(item => Number(item.humidity)).join('+')) / partList.length
			});
			console.log(JSON.stringify({
				infraredBase: infraredBase,
				detectionList: detectionList,
				deviceList: deviceList,
				partList: partList
			}))
			return {
				infraredBase: infraredBase,
				detectionList: detectionList,
				deviceList: deviceList,
				partList: partList
			}
		},
		getName(data) {
			console.log(data)
			if (data) {
				let list = []
				data.split(',').map((v) => {
					list.push(v.split(']')[1])
				})
				return list.join(',');
			} else {
				return data
			}

		},
		// 保存提交
		save(type) {
			var that = this
			if (type) {
				let check = true;
				let params = this.dealParamData()
				if (!this.baseForm.dtcInstrument) {
					check = false
					mui.toast("请输入检测仪器");
				}
				params.deviceList.map((v, i) => {
					if (!v.bay || !v.deviceName) {
						check = false
						mui.toast("请输入设备信息");
					}
				})
				console.log(JSON.stringify(params.partList))
				params.partList.map((v, i) => {
					
					if (!v.partName || !v.surfaceTA || !v.surfaceTB || !v.surfaceTC || !v.ambientT || !v.humidity || !v.defectPart) {
						console.log(v.partName)
						check = false
						mui.toast("请输入部位信息");
					}
				})
				if (check) {
					this.cfmData.type = this.workStatus < '40' ? 'submit' : 'forward'; // 推进类型（forward：向前、backward：向后）
					this.cfmData = Object.assign({}, this.cfmData, params);
					// 已检查设备数量
					let deviceNames = [];
					this.cfmData.deviceNum = this.cfmData.deviceList.filter(item => {
						let itNameNotIn = item.deviceName != '' && deviceNames.indexOf(item.deviceName) == -1;
						if (itNameNotIn) {
							deviceNames.push(item.deviceName);
						}
						return itNameNotIn;
					}).length;
					this.isApprove = check;
				}
			} else {
				// 保存
				let params = this.dealParamData();
				params.currentUser = this.currentUser
				mui.neiosRequst.httpRequst('/app/regularWork/infrared/saveInfraredDetails', params,
					(data) => {
						if (data.code == '0') {
							console.log(JSON.stringify(data.data))
							mui.toast('保存成功')
							setTimeout(function() {
								that.goBack()
							}, 1000);

						}
					},
					(data) => {
						mui.toast("获取数据错误：" + data.msg);
					}
				);
			}
		},
		// 提交
		openSubmit() {
			this.toDoWhat(this.cfmData.type)
		},
		// 判断提交类型
		toDoWhat(type) {
			if (type == 'submit') { // 提交
				if (this.cfmData.workStatus == '30' && this.cfmData.type != 'backward') {
					if (this.$refs.personselect.person) {
						this.cfmData.approver = this.$refs.personselect.person
						this.cfmData.strName = this.getName(this.$refs.personselect.person)
						this.cfmData.strCode = this.$refs.personselect.personids
						this.submit(this);
					} else {
						mui.toast("请选择审批人");
					}
				} else {
					this.submit();
				}
			} else if (type == 'backward') { // 退回
				if (this.cfmData.opinion) {
					this.backward();
				} else {
					mui.toast("请输入意见描述");
				}
			} else if (type == 'forward') { // 通过
				this.forward();
			}
		},
		// 提交
		submit() {
			this.cfmData.currentUser = this.currentUser
			mui.neiosRequst.httpRequst('/app/regularWork/infrared/submitInfraredDetails', this.cfmData,
				(data) => {
					if (data.code == '0') {
						mui.toast("提交成功");
						this.goBack()
					}
				},
				(data) => {
					mui.toast("提交失败");
				}
			);
		},
		// 退回
		backward() {
			let param = {
				"workId": this.cfmData.workId,
				"workType": this.cfmData.workType,
				"workDesc": this.cfmData.workDesc,
				"nodeDealStaffCode": this.currentUser.userId,
				"nodeDealStaffName": this.currentUser.name,
				"approveDesc": this.cfmData.opinion,
				"nodeDealStaffRole": '0',
				"forwardNode": '1',
				"nodeVisibleRange": '20',
				"questionArr":this.cfmData.questionArr
			};
			console.log(JSON.stringify(param))
			mui.neiosRequst.httpRequst('/app/personWork/sendBack', param,
				(data) => {
					if (data.code == '0') {
						mui.toast("退回成功");
						this.goBack()
					}
				},
				(data) => {
					mui.toast("退回失败");
				}
			);
		},
		// 通过
		forward() {
			this.cfmData.approveDes = this.cfmData.opinion;
			mui.neiosRequst.httpRequst('/app/regularWork/infrared/approveInfraredDetails', this.cfmData,
				(data) => {
					if (data.code == '0') {
						mui.toast("审批成功");
						this.goBack()
					}
				},
				(data) => {
					mui.toast("审批失败");
				}
			);
		},
		// 当缺陷部位输入框失去焦点时
		onPartBlur(type) {
			if (type == 'defectPart') {
				this.cfmData.questionArr = [];
				this.setDefectList();
				this.baseForm.dtcResult = this.cfmData.questionArr.map((item, index) => (index + 1) + '、' + item.name).join(
					'\n');
			}
		},
		// 设置缺陷描述列表
		setDefectList(type) { 
			this.detectionList.map((item, index) => {
				this.deviceForm.tableData.map((it, ix) => {
					if (it.infraredDetectionId == item.infraredDetectionId && it.dataStatus != '0') {
						this.partForm.tableData.map((pit, pix) => {
							if (pit.infraredDeviceId == it.infraredDeviceId && pit.dataStatus != '0' && pit.defectPart != '') {
								let defectDesc = it.bay + '，' + it.deviceName + '，' + '存在缺陷部位：' + pit.partName + '，' + pit.defectPart +
									'。';
								this.cfmData.questionArr.push({
									name: defectDesc
								});
							}
						});
					}
				});
			});
		},
		//返回上一页
		goBack() {
			let page2 = plus.webview.getWebviewById("../sitOperation/terminalwork/terminalwork.html");
			let param = {}
			param.isRefresh = true
			mui.fire(page2, 'isRefresh', param);
			mui.back()
		},
		//新巡视人若编辑了历史信息则对应巡视人为新巡视人否则保持为原巡视人
		// changeCheck() {
		// 	this.formData.checkStaffCode = this.currentUser['userId'];
		// 	this.formData.checkStaffName = this.currentUser['name'];
		// 	this.formData.checkStaffCodeName = this.currentUser['userName'];
		// },
		//点击菜单
		menuClick(e) {
			this.navTo(e.path)

		},
		//左上角菜单显示隐藏
		showMenulist() {
			this.showMenu ? this.showMenu = false : this.showMenu = true
		},
		//切换筛选条件
		changeFliter(e) {
			this.filterText = e
		},
		showPop() {
			this.show_popup = true
		},
		hidePopup() {
			this.show_popup = false
		},

	}

})



// mui.init({
// 	pullRefresh: {
// 		container: "#scroll", //待刷新区域标识，querySelector能定位的css选择器均可，比如：id、.class等
// 		down: { //下拉刷新
// 			style: 'circle',
// 			height: 50, //可选,默认50.触发下拉刷新拖动距离,
// 			auto: false, //可选,默认false.首次加载自动下拉刷新一次
// 			contentdown: "下拉可以刷新", //可选，在下拉可刷新状态时，下拉刷新控件上显示的标题内容
// 			contentover: "释放立即刷新", //可选，在释放可刷新状态时，下拉刷新控件上显示的标题内容
// 			contentrefresh: "正在刷新...", //可选，正在刷新状态时，下拉刷新控件上显示的标题内容
// 			callback: async function() { //必选，刷新函数，根据具体业务来编写，比如通过ajax从服务器获取新数据；
// 				page = 0;

// 				////没有更多内容了，endPulldown 传入true， 不再执行下拉刷新
// 				mui('#scroll').pullRefresh().endPulldownToRefresh();
// 				mui('#scroll').pullRefresh().enablePullupToRefresh();
// 				mui('#scroll').pullRefresh().endPullupToRefresh(true);
// 			}
// 		},
// 		up: { //上拉加载
// 			height: 50, //可选.默认50.触发上拉加载拖动距离
// 			auto: false, //可选,默认false.自动上拉加载一次
// 			contentrefresh: "正在加载...", //可选，正在加载状态时，上拉加载控件上显示的标题内容
// 			contentnomore: '没有更多数据了', //可选，请求完毕若没有更多数据时显示的提醒内容；
// 			callback: async function() { //必选，刷新函数，根据具体业务来编写，比如通过ajax从服务器获取新数据；

// 			}
// 		}
// 	}
// });
